import * as path from "path";

export function hasExt(filePath:string):boolean{
    const baseName = path.basename(filePath);
    return baseName.includes(".");
}

export function startsWithDot(filePath: string, checkDir?: boolean): boolean {
    const baseName = path.basename(filePath);
    return checkDir ? /[/\\]\./.test(filePath) : baseName.startsWith(".")
}

export function getExt(filePath: string): string{
    const baseName = path.basename(filePath);
    const fields = baseName.split(".");
    if (fields.length == 1) {
        return "无后缀";
    }
    else {
        fields.shift();
        let ext = fields.join(".");
        return `.${ext}`;
    }
}